<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>建议及意见</title>
    <link rel="stylesheet" th:href="@{/css/tip.css}"/>
    <link th:replace="common/header"/>
    <script type="text/javascript" th:src="@{/js/layer/tip.js}"></script>
</head>

<body class="no-skin">
<div th:replace="common/top"/>
<div class="main-container ace-save-state" id="main-container">
    <div th:replace="common/menu"/>
    <div class="main-content">
        <div class="main-content-inner">
            <div th:replace="common/title"/>
            <div class="page-content">
                <div th:replace="common/skin"/>
                <div class="page-header">
                    <h1>
                        建议及意见
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            欢迎对我们的网站提出建议及意见
                        </small>
                    </h1>
                </div><!-- /.page-header -->

                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" role="form" id="form" th:action="@{/addSuggestInfo}"
                              th:method="post" th:object="${suggestInfo}" onsubmit="return false" action="#">
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-top"> 欢迎度 </label>
                                <div class="col-sm-9">
                                    <div class="rating inline"></div>
                                    <div class="hr hr-16 hr-dotted"></div>
                                </div>
                            </div>
                            <div class="space-6"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-top"> 意见及建议 </label>
                                <div class="col-sm-6">
                                    <textarea name="content" id="content" class="input_fix" cols="100"
                                              placeholder="意见及建议" th:value="*{content}"></textarea>
                                </div>
                            </div>
                            <div class="space-6"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-top"> 联系电话 </label>
                                <div class="col-sm-6">
                                    <input name="phone" id="phone" type="text" class="input_fix" placeholder="联系电话"
                                           th:value="*{phone}"/>
                                </div>
                            </div>
                            <div class="space-6"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-top"> E-mail </label>
                                <div class="col-sm-6">
                                    <input name="email" id="email" type="text" class="input_fix" placeholder="E-mail"
                                           th:value="*{email}"/>
                                </div>
                            </div>
                            <div class="space-6"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-top"> 类型 </label>
                                <div class="col-sm-6">
                                    <select th:field="*{type}" name="type" id="type" type="text" class="input_fix"
                                            th:value="*{type}">
                                        <option value="">--请选择--</option>
                                        <option th:each="type : ${T(xyz.ibenben.zhongdian.system.entity.enums.SuggestTypeEnum).values()}"
                                                th:value="${type}"
                                                th:text="${type.text}"></option>
                                    </select>
                                </div>
                            </div>
                            <div class="space-6"></div>
                            <div class="row-fluid">
                                <div class="text-center span12">
                                    <button shiro:hasPermission="/addSuggestInfo" class="btn btn-primary" id="submit"
                                            type="button">
                                        <i class="fa fa-floppy-o" aria-hidden="true"></i>提交
                                    </button>
                                    <button shiro:hasPermission="/addSuggestInfo" class="btn btn-danger" type="reset"><i
                                            class="fa fa-times" aria-hidden="true"></i>取消
                                    </button>
                                    <a class="btn" href="/"
                                       th:href="@{/}"><i class="fa fa-reply" aria-hidden="true"></i>首页</a>
                                </div>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->
    </div><!-- /.main-container -->
    <div th:replace="common/footer"/>
</div>
<div th:replace="common/buttom"/>
<div th:replace="common/layer"/>
</body>
</html>
<script th:src="@{/js/common/jquery.raty.min.js}"></script>
<script>
    var setRatingColors = function () {
        $(this).find('.star-on-png,.star-half-png').addClass('orange2').removeClass('grey');
        $(this).find('.star-off-png').removeClass('orange2').addClass('grey');
    }
    $('.rating').raty({
        'cancel': false,
        'half': true,
        'starType': 'i',
        'click': function () {
            setRatingColors.call(this);
        }
    });
    $("#submit").click(function () {
        $.ajax({
            url: "/addSuggestInfo",
            type: "post",
            dataType: "json",
            data: $('#form').serialize(),
            success: function (json) {
                if (json.success) {
                    showTip('提交成功', 4000);
                } else {
                    showTip('提交失败', 4000);
                }
            }
        });
    });
</script>
